from pydantic import BaseModel, Field
from typing import Optional
from fastapi import Query


class DeptQuery(BaseModel):
    page: int = Field(1, ge=1, description="页码", alias="current")
    size: int = Field(10, ge=1, le=100, description="每页数量")
    dept_name: Optional[str] = Field(None, description="事业部名称筛选")
    dept_code: Optional[str] = Field(None, description="事业部编码筛选")
    status: Optional[bool] = Field(None, description="状态筛选：True启用，False禁用")
    keyword: Optional[str] = Field(None, description="关键词搜索（名称/编码/主管/描述）")


def dept_list_query(
    page: int = Query(1, ge=1, description="页码"),
    size: int = Query(10, ge=1, le=100, description="每页数量"),
    dept_name: Optional[str] = Query(None, description="事业部名称筛选"),
    dept_code: Optional[str] = Query(None, description="事业部编码筛选"),
    status: Optional[bool] = Query(None, description="状态筛选"),
    keyword: Optional[str] = Query(None, description="关键词搜索"),
) -> DeptQuery:
    return DeptQuery(
        page=page,
        size=size,
        dept_name=dept_name,
        dept_code=dept_code,
        status=status,
        keyword=keyword,
    )